package cn.tedu.hm.controller;

import cn.tedu.hm.pojo.dto.OpinionAddNewDTO;
import cn.tedu.hm.pojo.dto.ServiceAddNewDTO;
import cn.tedu.hm.pojo.vo.OpinionListItemVO;
import cn.tedu.hm.pojo.vo.OpinionStandardVO;
import cn.tedu.hm.pojo.vo.RoomStandardVO;
import cn.tedu.hm.pojo.vo.ServiceListItemVO;
import cn.tedu.hm.service.IOpinionService;
import cn.tedu.hm.service.IServiceService;
import cn.tedu.hm.wep.JsonPage;
import cn.tedu.hm.wep.JsonResult;
import cn.tedu.hm.wep.WebConsts;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author tj41h
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/opinion/")
@Api(tags="12. 顾客意见列表模块")
@Transactional
public class OpinionController {

    @Autowired
    private IOpinionService opinionService;


    @PostMapping("new")
    @ApiOperation("新增顾客意见")
    @ApiOperationSupport(order = 410)
    public JsonResult<Void> New(OpinionAddNewDTO opinionAddNewDTO){
        log.debug("开始执行生成服务的请求，参数为{}",opinionAddNewDTO);
        opinionService.add(opinionAddNewDTO);
        return JsonResult.ok();
    }



    @GetMapping("")
    @ApiOperation("查询顾客意见列表")
    @ApiOperationSupport(order = 420)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页码",name="page",example = "1"),
            @ApiImplicitParam(value = "每页条数",name="pageSize",example = "10")
    })
    public JsonResult<JsonPage<OpinionListItemVO>> list(
            @RequestParam(required = false,defaultValue = WebConsts.DEFAULT_PAGE)
            Integer page,
            @RequestParam(required = false,defaultValue = WebConsts.DEFAULT_PAGE_SIZE)
            Integer pageSize
    ) {
        log.debug("开始处理【查询服务列表】的请求，参数:{},{}",page,pageSize);
        JsonPage<OpinionListItemVO> list = opinionService.list(page, pageSize);
        return JsonResult.ok(list);
    }

    @GetMapping("selectByType")
    @ApiOperation("根据Type查询房间详情")
    @ApiOperationSupport(order = 431)
    public JsonResult<JsonPage<OpinionStandardVO>> selectByRoomType(String type, Integer page, Integer pageSize) {
        log.debug("开始处理【根据房间类型查询房间详情】的请求，参数：{}", type);
        JsonPage<OpinionStandardVO> queryResult = opinionService.getStandardByType(type, page, pageSize);
        log.debug("data{}", queryResult);
        return JsonResult.ok(queryResult);
    }



}
